package com.weixin.project.Specification;

import com.weixin.project.Entity.Video;
import org.springframework.data.jpa.domain.Specification;

public class VideoSpecification {
    public static Specification<Video> titleContains(String text) {
        return (root, query, cb) -> {
            if (text == null || text.equals("")) {
                return null;
            }
            javax.persistence.criteria.Predicate[] predicates = new javax.persistence.criteria.Predicate[1];
            predicates[0] = cb.like(root.get("title"), "%" + text + "%");
            return cb.and(predicates);
        };
    }
}
